package com.sccba.uop.demo.util.algorithm;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * base64工具
 */
public class Base64Utils {

    public static String encodeToString(byte[] bytes){
        byte[] encodeBytes = encode(bytes);
        return new String(encodeBytes,StandardCharsets.UTF_8);
    }

    public static byte[] decode(String str){
        return decode(str.getBytes(StandardCharsets.UTF_8));
    }

    public static byte[] encode(byte[] bytes) {
        return Base64.getEncoder().encode(bytes);
    }

    public static byte[] decode(byte[] bytes) {
        return Base64.getDecoder().decode(bytes);
    }



}
